from django.db import models

# Create your models here.


#教师表
class TeachInfo(models.Model):
    user=models.CharField(verbose_name='教师姓名',max_length=32,null=True,blank=True)
    pwd = models.CharField( verbose_name='密码', max_length=64,null=True,blank=True)
    TeacherID=models.CharField(verbose_name='教师号',max_length=32,null=True,blank=True)
    modlie = models.CharField(verbose_name='手机号', max_length=11,null=True,blank=True)
    age = models.IntegerField(verbose_name='年龄',null=True,blank=True)
    sex_choies = (
        (1, '男'),
        (2, '女')
    )
    sex = models.SmallIntegerField(verbose_name='性别', choices=sex_choies,null=True,blank=True)
    h_type=models.CharField(verbose_name='状态',max_length=32,default='0')

    def __str__(self):
        return self.user

# #学生表
class StudentInfo(models.Model):
    user=models.CharField(verbose_name='学生姓名',max_length=32,null=True,blank=True)
    pwd=models.CharField(verbose_name='密码',max_length=64,null=True,blank=True)
    StudentID = models.CharField(verbose_name='学号', max_length=32,null=True,blank=True,error_messages={'required':'学号不能为空','unique':'学号已存在','min_length':'长度不能小于3个字符','max_length':'长度不能大于11个字符'})
    Studentmodlie = models.CharField(verbose_name='手机号', max_length=11,null=True,blank=True,unique=True,error_messages={'unique':'手机号码已存在','min_length':'长度不能小于3个字符','max_length':'长度不能大于11个字符'})
    Studentage = models.IntegerField(verbose_name='年龄',null=True,blank=True)
    sex_choies = (
        (1, '男'),
        (2, '女')
    )
    Studentsex = models.SmallIntegerField(verbose_name='性别', choices=sex_choies,null=True,blank=True)
    h_type = models.CharField(verbose_name='状态', max_length=32,default='1')
    teach = models.ForeignKey( to="TeachInfo", to_field='id', on_delete=models.CASCADE, verbose_name='班主任',default=1)

    #将值传给其他页面调用
    def __str__(self):
      return  self.user

# #管理员表
class AdminInfo(models.Model):
    user= models.CharField( verbose_name='管理员名称', max_length=32 )
    pwd = models.CharField( verbose_name='密码', max_length=64 )
    h_type = models.CharField(verbose_name='状态', max_length=32,default='2')

    #将值传给其他页面调用
    def __str__(self):
      return  self.user

# #课程信息表
class CourseTable(models.Model):
    sections=models.CharField(verbose_name='节次',max_length=64)
    monday=models.CharField(verbose_name='星期一课程',max_length=256,null=True,blank=True)
    tuesday=models.CharField(verbose_name='星期二课程',max_length=256,null=True,blank=True)
    wednesday=models.CharField(verbose_name='星期三课程',max_length=256,null=True,blank=True)
    thursday=models.CharField(verbose_name='星期四课程',max_length=256,null=True,blank=True)
    friday=models.CharField(verbose_name='星期五课程',max_length=256,null=True,blank=True)


#学生请假表
class StudentLeave(models.Model):
    # oid=models.IntegerField(verbose_name='请假单号',default=200000003333333)
    name=models.CharField(verbose_name='姓名',max_length=32)
    sex_choices=(
        (1,'男'),
        (2,'女')
    )
    sex=models.SmallIntegerField(verbose_name='性别',choices=sex_choices,default=1)
    age=models.IntegerField(verbose_name='年龄')
    xueID = models.CharField(verbose_name='学号', max_length=32, null=True, blank=True)
    test=models.TextField(verbose_name='请假内容', max_length=128)
    times=models.DateField(verbose_name='请假时间')
    retime=models.DateField(verbose_name='销假时间', null=True, blank=True )
    level_choices = (
        (1, '已请假'),
        (2, '未销假'),
        (3, '已销假')
    )
    level = models.SmallIntegerField(verbose_name='请假状态', choices=level_choices, default=1)

    teachers = models.ForeignKey(verbose_name='班主任', to=TeachInfo, on_delete=models.CASCADE)
    teacher_exam_choices=(
        (1,'已审核'),
        (2,'未审核')
    )
    teacher_exam=models.SmallIntegerField(verbose_name='班主任审核', choices=teacher_exam_choices, default=2)
    exam_choices = (
        (1, '已审批'),
        (2, '待审批'),
        (3, '未通过')
    )
    exam = models.SmallIntegerField(verbose_name='审批状态', choices=exam_choices, default=2)
    admins=models.ForeignKey(verbose_name='审核员',to=AdminInfo,on_delete=models.CASCADE,null=True, blank=True )

#教师请假表
class TeacherLeave(models.Model):
    # oid=models.IntegerField(verbose_name='请假单号',default=200000003333333)
    name = models.CharField(verbose_name='姓名', max_length=32)
    sex_choices = (
        (1, '男'),
        (2, '女')
    )
    sex = models.SmallIntegerField(verbose_name='性别', choices=sex_choices, default=1)
    age = models.IntegerField(verbose_name='年龄')
    teacherID = models.CharField(verbose_name='教师号', max_length=32, null=True, blank=True)
    test = models.TextField(verbose_name='请假内容', max_length=128)
    times = models.DateField(verbose_name='请假时间')
    retime = models.DateField(verbose_name='销假时间', null=True, blank=True)
    level_choices = (
        (1, '已请假'),
        (2, '未销假'),
        (3, '已销假')
    )
    level = models.SmallIntegerField(verbose_name='请假状态', choices=level_choices, default=1)
    exam_choices = (
        (1, '已审批'),
        (2, '待审批'),
        (3, '未通过')
    )
    exam = models.SmallIntegerField(verbose_name='审批状态', choices=exam_choices, default=2)
    admins = models.ForeignKey(verbose_name='审核员', to=AdminInfo, on_delete=models.CASCADE,null=True, blank=True )

#学生成绩表
class StudentScore(models.Model):
    StudentName =models.ForeignKey(verbose_name='学生姓名', to=StudentInfo, on_delete=models.CASCADE,null=True, blank=True,related_name='scores')
    language=models.IntegerField(verbose_name='语文成绩', null=True, blank=True)
    maths = models.IntegerField(verbose_name='数学成绩', null=True, blank=True)
    English = models.IntegerField(verbose_name='英语成绩', null=True, blank=True)
    history = models.IntegerField(verbose_name='历史成绩', null=True, blank=True)
    Geography = models.IntegerField(verbose_name='地理成绩',null=True, blank=True)
    political=models.IntegerField(verbose_name='政治成绩',null=True,blank=True)
    total=models.IntegerField(verbose_name='总分',null=True,blank=True)
#评价信息表
class InformationTables(models.Model):
    Texts=models.TextField(verbose_name='教学反馈',max_length=128,null=True, blank=True)
    rmation = models.TextField(verbose_name='教学评价', max_length=128,null=True, blank=True)
    Releasetime= models.DateField(verbose_name='发布时间',null=True, blank=True)
    teacherRmation=models.ForeignKey(verbose_name='发起人',to=TeachInfo,on_delete=models.CASCADE,null=True, blank=True)


class StudentInformationTable(models.Model):
    StudentName=models.CharField(verbose_name='学生姓名',max_length=64,null=True, blank=True)
    StudentID=models.IntegerField(verbose_name='学号',null=True, blank=True)
    sex_choices = (
        (1, '男'),
        (2, '女')
    )
    sex = models.SmallIntegerField(verbose_name='性别', choices=sex_choices,null=True, blank=True)
    Texts=models.TextField(verbose_name='教学反馈',max_length=128,null=True, blank=True)
    rmation = models.TextField(verbose_name='教学评价', max_length=128,null=True, blank=True)
    Filltime=models.DateField(verbose_name='填写时间', null=True, blank=True)
    teacherRmation=models.ForeignKey(verbose_name='发起人',to=TeachInfo,on_delete=models.CASCADE,null=True, blank=True)
    teacher_exam_choices = (
        (1, '已审核'),
        (2, '未审核')
    )
    tables = models.SmallIntegerField(verbose_name='审核状态', choices=teacher_exam_choices, default=2)
    examRmation_choices = (
        (1, '已审批'),
        (2, '待审批'),
        (3, '未通过')
    )
    examRmation = models.SmallIntegerField(verbose_name='审批状态', choices=examRmation_choices, default=2)
    adminRmation = models.ForeignKey(verbose_name='审核员', to=AdminInfo, on_delete=models.CASCADE, null=True, blank=True)